from skimage import io,util,exposure
import numpy as np

def add_gaussian_noise(X):
    X_noise = []
    for i in range(len(X)):
        X_noise.append(util.random_noise
                       (image=X[i],var=((25/255.)**2)*np.random.uniform(0,1))*255)
    return np.asarray(X_noise)

def darken(X):
    X_darked = []
    for i in range(len(X)):
        gamma=np.random.uniform(2,5)
        X_darked.append(exposure.adjust_gamma(X[i],gamma))
    return np.asarray(X_darked)

def crop_center_board_6(imgs):
    imgs_resized = []
    for i in range(len(imgs)):
        imgs_resized.append(util.crop(imgs[i],6))
    print imgs_resized[0].shape
    return np.asarray(imgs_resized)

def crop_center_board_3(imgs):
    imgs_resized = []
    for i in range(len(imgs)):
        imgs_resized.append(util.crop(imgs[i],3))
    print imgs_resized[0].shape
    return np.asarray(imgs_resized)

def crop_center_board(imgs,board_size=6):
    imgs_resized = []
    for i in range(len(imgs)):
        imgs_resized.append(util.crop(imgs[i],board_size))
    print imgs_resized[0].shape
    return np.asarray(imgs_resized)